#pragma once

class CFileLibraryDoc;

class FileChangeNotify
{
public:
	static bool WatchDriver(TCHAR letter, CFileLibraryDoc* doc);
	static UINT GetWatchingDriver();
	static UINT GetWatcherCount();
	static bool CloseWatcher(TCHAR letter);
	static bool Initalize(UINT driverstates, CFileLibraryDoc* doc);
	static void Release();
private:
	FileChangeNotify();

	static CCriticalSection threadsSection;

	struct WatchParameter
	{
		CFileLibraryDoc* doc;
		LPTSTR path;
		HANDLE returnEvent;
	};
	struct DriverThreadInfo
	{
		CWinThread* thread;
		TCHAR letter;
		HANDLE returnEvent;
	};
	static CArray<DriverThreadInfo*,DriverThreadInfo*> threads;

	static UINT WatchFileChange(LPVOID para);
	static UINT CloseWatcherFunc(LPVOID para);
};